﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace FileApps
{
    public class LinesOfCodeMock : ILinesOfCode
    {

        private int _TotalLines;
        private int _CommentLines;
        private int _EmptyLines;
        private int _BracketLines;
        private int _CodeLines;
        private string _fileName;
        private string[] lines;
        public List<Exception> Exceptions = new List<Exception>();

        public LinesOfCodeMock(string path)
        {
            GetFileInfo(path);
            ParseLines();
        }
        
        
        private void ParseLines()
        {
            _TotalLines = 14;
            _EmptyLines = 2;
            _BracketLines = 4;
            _CommentLines = 5;
            _CodeLines = _TotalLines - _EmptyLines - _BracketLines - CommentLines;
        }

        private void GetFileInfo(string path)
        {
            try
            {
                _fileName = new FileInfo(path).Name;
                lines = File.ReadAllLines(path);
            }
            catch (NullReferenceException nre)
            {
                Exceptions.Add(nre);
            }
            catch (AccessViolationException ave)
            {
                Exceptions.Add(ave);
            }
            catch (IOException ioe)
            {
                Exceptions.Add(ioe);
            }
        }

        #region ILinesOfCode Members

        public string FileName
        {
            get
            {
                return _fileName;
            }
        }

        public int TotalLines
        {
            get
            {
                return _TotalLines;
            }
        }

        public int CommentLines
        {
            get
            {
                return _CommentLines;
            }
        }

        public int EmptyLines
        {
            get
            {
                return _EmptyLines;
            }
        }

        public int CodeLines
        {
            get { return _CodeLines; }
        }

        public int BracketLines
        {
            get { return _BracketLines; }
        }

        #endregion

        #region ILinesOfCode Members


        public Dictionary<int, string> EmptyLineDictionary
        {
            get
            {
                throw new NotImplementedException();
            }
            protected set
            {
                throw new NotImplementedException();
            }
        }

        public Dictionary<int, string> BracketLineDictionary
        {
            get
            {
                throw new NotImplementedException();
            }
            protected set
            {
                throw new NotImplementedException();
            }
        }

        public Dictionary<int, string> CommentLineDictionary
        {
            get
            {
                throw new NotImplementedException();
            }
            protected set
            {
                throw new NotImplementedException();
            }
        }

        public Dictionary<int, string> CodeLineDictionary
        {
            get
            {
                throw new NotImplementedException();
            }
            protected set
            {
                throw new NotImplementedException();
            }
        }

        #endregion
    }
}
